#ifndef WF_DIMENSION_H
#define WF_DIMENSION_H

#include "pf_previewactioninterface.h"
#include "pf_dimension.h"
#include "gui_export.h"
/**
 * Base class for dimension actions.
 *
 */
class GUI_EXPORT WF_Dimension : public PF_PreviewActionInterface {
    Q_OBJECT
public:
    WF_Dimension(const char* name,
                       PF_Container& container,
                       PF_GraphicView& graphicView);
    ~WF_Dimension();

    virtual void reset();

    virtual void init(int status=0);

    virtual void hideOptions();
    virtual void showOptions();

    virtual void updateMouseCursor();
    virtual void updateToolBar();

    PF_String getText() {
		if (!data.text.isEmpty()) {
			return data.text;
		}
	
        PF_String l = label;

        if (l.isEmpty() &&
            (diameter==true || !tol1.isEmpty() || !tol2.isEmpty())) {
            l = "<>";
        }

        if (diameter==true) {
            l = QChar(0x2205) + l;
        }

        if (!tol1.isEmpty() || !tol2.isEmpty()) {
            l += PF_String("\\S%1\\%2;").arg(tol1).arg(tol2);
        }

        return l;
    }
	
    void setText(const PF_String& t) {
        data.text = t;
	}

	PF_String getLabel() {
		return label;
	}
    void setLabel(const PF_String& t) {
        //data.text = t;
        label = t;
    }
	PF_String getTol1() {
		return tol1;
	}
    void setTol1(const PF_String& t) {
        tol1 = t;
    }
	PF_String getTol2() {
		return tol2;
	}
    void setTol2(const PF_String& t) {
        tol2 = t;
    }
	bool getDiameter() {
		return diameter;
	}
    void setDiameter(bool d) {
        diameter = d;
    }

    static bool isDimensionAction(LX_Define::ActionType type) {
        return (type==LX_Define::ActionDimAligned ||
                type==LX_Define::ActionDimLinear ||
                type==LX_Define::ActionDimAngular ||
                type==LX_Define::ActionDimDiametric ||
                type==LX_Define::ActionDimRadial);
    }

protected:
    /**
     * Generic dimension data.
     */
    PF_DimensionAttribute data;

    PF_String label;
    PF_String tol1;
    PF_String tol2;
    bool diameter;


    /**
     * Commands.
     */
    /*
      PF_String cmdText;
      PF_String cmdText2;
    */
};

#endif
